import axios from 'common/js/token/request'

export function getRequests(PageNumber, PageSize) {
  return axios.get('/api/Orders/cashback/requestedOrders', {
    params: {
      PageNumber,
      PageSize
    }
  })
    .then((res) => {
      return Promise.resolve(res.data)
    })
    .catch((err) => {
      console.log(err)
    })
}

export function getTotal() {
  const url = '/api/Orders/cashback/requestedOrders/totalRebate'
  return axios.get(url)
    .then(res => {
      return Promise.resolve(res.data)
    })
    .catch(err => {
      console.log(err)
    })
}

export function getRequestDetail(num) {
  const url = '/api/Orders/' + num
  return axios.get(url)
    .then(res => {
      return Promise.resolve(res.data)
    })
    .catch(err => {
      console.log(err)
    })
}
export function getRequestDetailUnsubmit(num) {
  const url = '/api/Orders/cashback/requestedOrders/' + num
  return axios.get(url)
    .then(res => {
      return Promise.resolve(res.data)
    })
    .catch(err => {
      console.log(err)
      return Promise.reject(err)
    })
}

//获取cart里的promotion总数
export function getCartAllTotal(num) {
  const url = '/api/ShoppingCart/productSummary'
  return axios.get(url)
    .then(res => {
      return Promise.resolve(res.data)
    })
    .catch(err => {
      console.log(err)
    })
}
